resource "google_bigquery_dataset" "<%= ctx[:primary_resource_id] %>" {
  dataset_id                  = "<%= ctx[:vars]['dataset_id'] %>"
  friendly_name               = "test"
  description                 = "This is a test description"
  location                    = "US"
  default_table_expiration_ms = 3600000

  default_encryption_configuration {
    kms_key_name = google_kms_crypto_key.crypto_key.id
  }
}

resource "google_kms_crypto_key" "crypto_key" {
  name     = "<%= ctx[:vars]['key_name'] %>"
  key_ring = google_kms_key_ring.key_ring.id
}

resource "google_kms_key_ring" "key_ring" {
  name     = "<%= ctx[:vars]['keyring_name'] %>"
  location = "us"
}
